package com.luminary.demo.business.api;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.luminary.demo.business.meta.BusinessApiConstants;
import com.luminary.demo.business.model.po.Business;
import com.luminary.demo.business.service.BusinessService;

@RefreshScope
@RestController
@RequestMapping(BusinessApiConstants.ROOT_PATH)
public class BusinessApi {

	@Autowired
	private BusinessService businessService;
	
	@GetMapping(BusinessApiConstants.GET_BY_USER_API)
	public Business getByUser(
			@PathVariable("username") String username,
			HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		return businessService.findByUser(username);
		
	}
	
}
